<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>bformenc1</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="bexprnd.html" title="bexprnd" />
    <link rel="next" href="bformdec1.html" title="bformdec1" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">bformenc1</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="bexprnd.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="bformdec1.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="bformenc1"></a>
      <div class="titlepage"></div>
      <a id="IndexBformenc1" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">bformenc1</span>
        </h2>
        <p>bformenc1 — 
      Codes a signal into the ambisonic B format.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92012112"></a>
        <h2>Description</h2>
        <p>
      Codes a signal into the ambisonic B format
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92013424"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">aw, ax, ay, az <span class="command"><strong>bformenc1</strong></span> asig, kalpha, kbeta</pre>
        <pre class="synopsis">aw, ax, ay, az, ar, as, at, au, av <span class="command"><strong>bformenc1</strong></span> asig, kalpha, kbeta</pre>
        <pre class="synopsis">aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq <span class="command"><strong>bformenc1</strong></span> \
      asig, kalpha, kbeta</pre>
        <pre class="synopsis">aarray[] <span class="command"><strong>bformenc1</strong></span> asig, kalpha, kbeta</pre>
      </div>
      <div class="refsect1">
        <a id="idp92020240"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>aw, ax, ay, ... </em></span>
      -- output cells of the B format.
    </p>
        <p>
      <span class="emphasis"><em>aarray</em></span>
      -- output array to hold cells of the B format.
    </p>
        <p>
      <span class="emphasis"><em>asig</em></span> -- input signal.
    </p>
        <p>
      <span class="emphasis"><em>kalpha</em></span> –- azimuth angle in degrees (anticlockwise).
    </p>
        <p>
      <span class="emphasis"><em>kbeta</em></span> -- altitude angle in degrees.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92025776"></a>
        <h2>Example</h2>
        <p>
      Here is an example of the bformenc1 opcode. It uses the file <a class="ulink" href="examples/bformenc1.csd" target="_top"><em class="citetitle">bformenc1.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp92027632"></a>
          <p class="title">
            <strong>Example 87. Example of the bformenc1 opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
<span class="comment">;-odac           -iadc     -d     ;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
 -o bformenc.wav -W <span class="comment">;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 8
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="oblock">instr</span> 1 <span class="comment">;without arrays</span>
<span class="comment">; generate pink noise</span>
anoise <span class="opc">pinkish</span> 1
        
<span class="comment">; two full turns</span>
kalpha <span class="opc">line</span> 0, p3, 720
kbeta <span class="op">=</span> 0
        
<span class="comment">; generate B format</span>
aw, ax, ay, az, ar, as, at, au, av <span class="opc">bformenc1</span> anoise, kalpha, kbeta
        
<span class="comment">; decode B format for 8 channel circle loudspeaker setup</span>
a1, a2, a3, a4, a5, a6, a7, a8 <span class="opc">bformdec1</span> 4, aw, ax, ay, az, ar, as, at, au, av        

<span class="comment">; write audio out</span>
<span class="opc">outo</span> a1, a2, a3, a4, a5, a6, a7, a8
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2 <span class="comment">;with arrays (csound6)</span>
<span class="comment">;set file names for:</span>
S_bform <span class="op">=</span> "bform_out.wav" <span class="comment">;b-format (2nd order) output</span>
S_sound <span class="op">=</span> "sound_out.wav" <span class="comment">;sound output</span>

<span class="comment">; generate pink noise</span>
anoise <span class="opc">pinkish</span> 1
        
<span class="comment">; two full turns</span>
kalpha <span class="opc">line</span> 0, p3, 720
kbeta <span class="op">=</span> 0
        
<span class="comment">;create array for B-format 2nd order (9 chnls)</span>
aBform[] <span class="opc">init</span> 9

<span class="comment">; generate B-format</span>
aBform <span class="opc">bformenc1</span> anoise, kalpha, kbeta

<span class="comment">;write out b-format</span>
<span class="opc">fout</span> "fout.wav", 18, aBform

<span class="comment">;create array for audio output (8 channels)</span>
aAudio[] <span class="opc">init</span> 8
        
<span class="comment">;decode B format for 8 channel circle loudspeaker setup</span>
aAudio <span class="opc">bformdec1</span> 4, aBform

<span class="comment">; write audio out</span>
<span class="opc">fout</span> S_sound, 18, aAudio
<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span> 1 0 8
<span class="stamnt">i</span> 2 8 8
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92031920"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="bformdec1.html" title="bformdec1"><em class="citetitle">bformdec1</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92034032"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Richard Furse, Bruce Wiggins and Fons
        Adriaensen, following code by Samuel Groner</td>
          </tr>
          <tr>
            <td>2008</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 5.09</p>
        <p>Array output new in version 6.01</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="bexprnd.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="bformdec1.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">bexprnd </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> bformdec1</td>
        </tr>
      </table>
    </div>
  </body>
</html>
